package servlet;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(urlPatterns ="/delannouncement")
public class andelServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        announcementServiceImpl service = new announcementServiceImpl();
        String announcement_num;
        try{
            announcement_num= req.getParameter("announcement_num");
        }
        catch(Exception e){
            announcement_num=null;
        }
        System.out.println(announcement_num);
        service.delete(announcement_num);
        resp.sendRedirect(req.getContextPath() + "success_del.jsp");
    }
}
